package com.nl.controller.xuyi.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nl.controller.common.annotation.SystemServiceLog;
import com.nl.controller.common.exception.SmsException;
import com.nl.controller.xuyi.bean.XuYiBlackUserInfo;
import com.nl.controller.xuyi.bean.XuYiOperatorInfo;
import com.nl.controller.xuyi.mapper.XuYiBlackMapper;
import com.nl.controller.xuyi.mapper.XuYiOperatorMapper;
import com.nl.controller.web.util.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
@Slf4j
public class XuYiBlackUserService {

    @Autowired
    private XuYiBlackMapper xuYiBlackMapper;


    @SystemServiceLog(description = "按照条件查询黑名单人员信息", value = false)
    public PageInfo<XuYiBlackUserInfo> findBlackUserByTel(int page, int limit, String phoneNumber) {
        PageHelper.startPage(page, limit);
        List<XuYiBlackUserInfo> xuYiBlackUserInfoList;
        xuYiBlackUserInfoList = xuYiBlackMapper.findBlackUserByTel(phoneNumber);
        PageInfo<XuYiBlackUserInfo> pageInfo = new PageInfo<>(xuYiBlackUserInfoList);
        return pageInfo;
    }

    
    @SystemServiceLog(description = "删除黑名单人员", value = false)
    public int deleteBlackUser(String phoneNumber) {
        int result;
        try {
            result = xuYiBlackMapper.deleteBlackUser(phoneNumber);
        } catch (Exception e) {
            e.printStackTrace();
            throw new SmsException("删除黑名单人员：" + phoneNumber);
        }
        return result;
    }


}
